package com.scuec.tourismwebsite.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.scuec.tourismwebsite.entity.PostComment;
import com.scuec.tourismwebsite.mapper.PostCommentMapper;
import com.scuec.tourismwebsite.vo.Fcomment;
import com.scuec.tourismwebsite.vo.PComment;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
//
import java.util.Collections;
import java.util.List;

@Service
public class PostCommentServiceImpl implements PostCommentService{
    @Autowired
    private PostCommentMapper postCommentMapper;

    @Override
    public Integer deletePCommentById(Integer comment_id) {
        return postCommentMapper.deletePCommentById(comment_id);
    }

    @Override
    public List<PComment> findPCommentByIdCo(Integer post_id, String comment_content) {
        return postCommentMapper.findPCommentByIdCo(post_id,comment_content);
    }

    @Override
    public List<PComment> findPCommentById(Integer post_id) {
        return postCommentMapper.findPCommentById(post_id);
    }

    @Override
    public PageInfo<PComment> findPCommentPages(Integer post_id, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<PComment> lists =postCommentMapper.findPCommentById(post_id);
        PageInfo<PComment> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public PageInfo<PComment> findPCommentPage(Integer post_id, String comment_content, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<PComment> lists = postCommentMapper.findPCommentByIdCo(post_id,comment_content);
        PageInfo<PComment> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public Integer insertPComment(PostComment postComment) {
        return postCommentMapper.insertPComment(postComment);
    }
}
